﻿using System;
using Microsoft.ServiceBus.Messaging;

namespace Nardax.Samples.ServiceBus
{
    public class NardaxBrokeredMessage : INardaxBrokeredMessage
    {
        private BrokeredMessage _brokeredMessage;

        public NardaxBrokeredMessage(BrokeredMessage brokeredMessage)
        {
            _brokeredMessage = brokeredMessage;
        }

        public NardaxBrokeredMessage(object serializableObject)
        {
            _brokeredMessage = new BrokeredMessage(serializableObject);
        }
        
        public T GetBody<T>()
        {
            return _brokeredMessage.GetBody<T>();
        }

        public IAsyncResult BeginComplete(AsyncCallback callback, object state)
        {
            return _brokeredMessage.BeginComplete(callback, state);
        }

        public void EndComplete(IAsyncResult result)
        {
            _brokeredMessage.EndComplete(result);
        }

        public void DeadLetter()
        {
            _brokeredMessage.DeadLetter();
        }

        public BrokeredMessage BrokeredMessage
        {
            get { return _brokeredMessage; }
            set { _brokeredMessage = value; }
        }
    }
}
